package com.bdqn.ch07.controller;

import com.bdqn.ch07.entity.User;
import com.bdqn.ch07.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class ExampleController {

    @Resource
    UserService userService;

    @ResponseBody
    @GetMapping(value = "/hello/{id}")
    public Object getUser(@PathVariable("id") Long usrId, Model model) {
        User user = userService.getUserByIdService(usrId);
        //model.addAttribute("user", user);
        //return "demo/hello";
        return user;
    }

}
